<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>The Grid: C:/GK/The Grid/TheGrid _doDokumentacji/graphic_engine/LogicLayer.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">The Grid
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">C:/GK/The Grid/TheGrid _doDokumentacji/graphic_engine/LogicLayer.h</div>  </div>
</div>
<div class="contents">
<a href="_logic_layer_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#pragma once</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span>
<a name="l00003"></a><a class="code" href="_logic_layer_8h.html#aa002aed8cc2633aba2600d4475fee154">00003</a> <span class="preprocessor">#define GRID_START_W 20 </span><span class="comment">/* startowa szerokosc */</span>
<a name="l00004"></a><a class="code" href="_logic_layer_8h.html#ae0c6c8a957b68296e2bc9b55b1ca10f7">00004</a> <span class="preprocessor">#define GRID_START_H 20 </span><span class="comment">/* startowa wysokosc */</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="comment">// Klasa - singleton - zarzadzajaca warstwa danych (mechanika i sterowanie)</span>
<a name="l00007"></a><a class="code" href="class_logic_layer.html">00007</a> <span class="keyword">class </span><a class="code" href="class_logic_layer.html">LogicLayer</a>
<a name="l00008"></a>00008 {
<a name="l00009"></a>00009 <span class="keyword">private</span>:
<a name="l00010"></a>00010         <span class="comment">// konstruktor inicjalizujacy </span>
<a name="l00011"></a>00011         <a class="code" href="class_logic_layer.html">LogicLayer</a>()
<a name="l00012"></a>00012     {   
<a name="l00013"></a>00013                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0;i&lt;256;i++)
<a name="l00014"></a>00014                         <a class="code" href="class_logic_layer.html#a5b113d312bf63c69a5d9d990d2a18466">keyStates</a>[i] = <span class="keyword">false</span>;
<a name="l00015"></a>00015                 <a class="code" href="class_logic_layer.html#a09cb7e24b330de168f35c2c21d3ccfa9">showFPSinfo</a> = <span class="keyword">false</span>;
<a name="l00016"></a>00016                 <span class="comment">//Bullet::bulletSpeed = 10;</span>
<a name="l00017"></a>00017 
<a name="l00018"></a>00018                 <a class="code" href="class_logic_layer.html#ae878777e53d3f4810f87e9d9f7a18a9e">grid</a> = <span class="keyword">new</span> <span class="keywordtype">int</span>*[<a class="code" href="_logic_layer_8h.html#aa002aed8cc2633aba2600d4475fee154">GRID_START_W</a>];
<a name="l00019"></a>00019                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="_logic_layer_8h.html#aa002aed8cc2633aba2600d4475fee154">GRID_START_W</a>;i++)
<a name="l00020"></a>00020                         <a class="code" href="class_logic_layer.html#ae878777e53d3f4810f87e9d9f7a18a9e">grid</a>[i] = <span class="keyword">new</span> <span class="keywordtype">int</span>[<a class="code" href="_logic_layer_8h.html#ae0c6c8a957b68296e2bc9b55b1ca10f7">GRID_START_H</a>];
<a name="l00021"></a>00021                 <a class="code" href="class_logic_layer.html#aef70ee015129649a4ebbb8b456ce9781">gridWidth</a> = <a class="code" href="_logic_layer_8h.html#aa002aed8cc2633aba2600d4475fee154">GRID_START_W</a>;
<a name="l00022"></a>00022                 <a class="code" href="class_logic_layer.html#a7a83a0a5220b0d8ea62388a3da9ca540">gridHeight</a> = <a class="code" href="_logic_layer_8h.html#ae0c6c8a957b68296e2bc9b55b1ca10f7">GRID_START_H</a>;
<a name="l00023"></a>00023                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="class_logic_layer.html#aef70ee015129649a4ebbb8b456ce9781">gridWidth</a>;i++)
<a name="l00024"></a>00024                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=0;j&lt;<a class="code" href="class_logic_layer.html#a7a83a0a5220b0d8ea62388a3da9ca540">gridHeight</a>;j++)
<a name="l00025"></a>00025                                 <a class="code" href="class_logic_layer.html#ae878777e53d3f4810f87e9d9f7a18a9e">grid</a>[i][j] = 0;
<a name="l00026"></a>00026 
<a name="l00027"></a>00027                 <a class="code" href="class_logic_layer.html#ab85cb7ae4750cb8b4bd14eafa47eec34">player</a> = <span class="keyword">new</span> <a class="code" href="classmap_item.html">mapItem</a>(<a class="code" href="map_item_8h.html#acfedb4dc867f15400ef304c029ceaf9fa5e396b688acecedf5e67a28ef0b0a5f2">MapItemTypePlayer</a>,10,10,5);
<a name="l00028"></a>00028                 <a class="code" href="class_logic_layer.html#a8963e4abd57f4958133820b3f7316cf3">creepRespawnCounter</a> = 0;
<a name="l00029"></a>00029                 <a class="code" href="class_logic_layer.html#a451f3530d7d022ef48a9b2af5aa50750">creepHardcore</a> = 0;
<a name="l00030"></a>00030                 <span class="comment">// wymuszenie startowego odswiezenia pozycji</span>
<a name="l00031"></a>00031                 <a class="code" href="class_logic_layer.html#aa97c5ce3cbeb13a157909b2a89f3f677">graphicsShouldRefreshBullets</a> = <span class="keyword">true</span>;
<a name="l00032"></a>00032                 <a class="code" href="class_logic_layer.html#aa965887d2920ef8344ff743e9c421d62">graphicsShouldRefreshCreeps</a> = <span class="keyword">true</span>;
<a name="l00033"></a>00033                 <a class="code" href="class_logic_layer.html#abe1e2ec25e7a908805856d985d98e599">graphicsShouldRefreshPlayer</a> = <span class="keyword">true</span>;
<a name="l00034"></a>00034                 <span class="comment">// startowe dane</span>
<a name="l00035"></a>00035                 <a class="code" href="class_logic_layer.html#a61b00b6e032f5b49944bbda89168f5fe">addCreep</a>(<a class="code" href="struct_point2_d.html">Point2D</a>(10,1),1);
<a name="l00036"></a>00036                 <a class="code" href="class_logic_layer.html#a61b00b6e032f5b49944bbda89168f5fe">addCreep</a>(<a class="code" href="struct_point2_d.html">Point2D</a>(1,19),1);
<a name="l00037"></a>00037                 <a class="code" href="class_logic_layer.html#a61b00b6e032f5b49944bbda89168f5fe">addCreep</a>(<a class="code" href="struct_point2_d.html">Point2D</a>(18,19),1);
<a name="l00038"></a>00038                 <span class="comment">// punkty</span>
<a name="l00039"></a>00039                 <a class="code" href="class_logic_layer.html#aeec1286e0b613d021fb4273c12522ce8">points</a> = 0;
<a name="l00040"></a>00040                 <span class="comment">// nie, jeszcze nie konczymy ;]</span>
<a name="l00041"></a>00041                 <a class="code" href="class_logic_layer.html#ab31c62e100fe1d5e2e7e542310f58bee">gameover</a> = <span class="keyword">false</span>;
<a name="l00042"></a>00042     }
<a name="l00043"></a>00043 <span class="keyword">public</span>:
<a name="l00044"></a>00044         <span class="comment">// tablica stanow klawiszy klawiatury</span>
<a name="l00045"></a><a class="code" href="class_logic_layer.html#a5b113d312bf63c69a5d9d990d2a18466">00045</a>         <span class="keywordtype">bool</span> <a class="code" href="class_logic_layer.html#a5b113d312bf63c69a5d9d990d2a18466">keyStates</a>[256]; 
<a name="l00046"></a>00046         <span class="comment">// tablica dla znakow specjalnych</span>
<a name="l00047"></a><a class="code" href="class_logic_layer.html#ae0d562efa90bdc42e10e9736fa762588">00047</a>         <span class="keywordtype">bool</span> <a class="code" href="class_logic_layer.html#ae0d562efa90bdc42e10e9736fa762588">specialKeystates</a>[256];
<a name="l00048"></a>00048         <span class="comment">// licznik ilosci przejsc funkcji doLogic od ostatniego respawnu creepa</span>
<a name="l00049"></a><a class="code" href="class_logic_layer.html#a8963e4abd57f4958133820b3f7316cf3">00049</a>         <span class="keywordtype">int</span> <a class="code" href="class_logic_layer.html#a8963e4abd57f4958133820b3f7316cf3">creepRespawnCounter</a>;
<a name="l00050"></a>00050         <span class="comment">// &#39;wzmacniacz wrazen&#39; - z kazdym dodanym creepem licznik zwieksza sie, zmniejszajac oczekiwanie na kolejny respawn. Limitowany na poziomie 20.</span>
<a name="l00051"></a><a class="code" href="class_logic_layer.html#a451f3530d7d022ef48a9b2af5aa50750">00051</a>         <span class="keywordtype">int</span> <a class="code" href="class_logic_layer.html#a451f3530d7d022ef48a9b2af5aa50750">creepHardcore</a>;
<a name="l00052"></a>00052         <span class="comment">// punkty zdobyte przez gracza</span>
<a name="l00053"></a><a class="code" href="class_logic_layer.html#aeec1286e0b613d021fb4273c12522ce8">00053</a>         <span class="keywordtype">int</span> <a class="code" href="class_logic_layer.html#aeec1286e0b613d021fb4273c12522ce8">points</a>;
<a name="l00054"></a>00054         <span class="comment">// kontrola konca gry</span>
<a name="l00055"></a><a class="code" href="class_logic_layer.html#ab31c62e100fe1d5e2e7e542310f58bee">00055</a>         <span class="keywordtype">bool</span> <a class="code" href="class_logic_layer.html#ab31c62e100fe1d5e2e7e542310f58bee">gameover</a>;
<a name="l00056"></a>00056         <span class="comment">// instancja gracza</span>
<a name="l00057"></a><a class="code" href="class_logic_layer.html#ab85cb7ae4750cb8b4bd14eafa47eec34">00057</a>         <a class="code" href="classmap_item.html">mapItem</a>* <a class="code" href="class_logic_layer.html#ab85cb7ae4750cb8b4bd14eafa47eec34">player</a>;
<a name="l00058"></a>00058         <span class="comment">// creepy</span>
<a name="l00059"></a><a class="code" href="class_logic_layer.html#a7d6239cac2c4b8bbb7a434cc2dc63418">00059</a>         std::vector&lt;mapItem*&gt; <a class="code" href="class_logic_layer.html#a7d6239cac2c4b8bbb7a434cc2dc63418">creepy</a>;
<a name="l00060"></a>00060         <span class="comment">// pociski</span>
<a name="l00061"></a><a class="code" href="class_logic_layer.html#a3894c1e0f64ce7084677ae80dae3d068">00061</a>         std::vector&lt;Bullet*&gt; <a class="code" href="class_logic_layer.html#a3894c1e0f64ce7084677ae80dae3d068">bullets</a>;
<a name="l00062"></a>00062         <span class="comment">// THE GRID, czyli plansza - int poniewaz liczylismy na dodanie specjalnych wlasciwosci zaleznie od pola</span>
<a name="l00063"></a><a class="code" href="class_logic_layer.html#ae878777e53d3f4810f87e9d9f7a18a9e">00063</a>         <span class="keywordtype">int</span> **<a class="code" href="class_logic_layer.html#ae878777e53d3f4810f87e9d9f7a18a9e">grid</a>; 
<a name="l00064"></a>00064         <span class="comment">// parametry grida</span>
<a name="l00065"></a><a class="code" href="class_logic_layer.html#aef70ee015129649a4ebbb8b456ce9781">00065</a>         <span class="keywordtype">int</span> <a class="code" href="class_logic_layer.html#aef70ee015129649a4ebbb8b456ce9781">gridWidth</a>,<a class="code" href="class_logic_layer.html#a7a83a0a5220b0d8ea62388a3da9ca540">gridHeight</a>;
<a name="l00066"></a>00066         <span class="comment">// informacja dla silnika graficznego by odswiezyl model i pozycje gracza</span>
<a name="l00067"></a><a class="code" href="class_logic_layer.html#abe1e2ec25e7a908805856d985d98e599">00067</a>         <span class="keywordtype">bool</span> <a class="code" href="class_logic_layer.html#abe1e2ec25e7a908805856d985d98e599">graphicsShouldRefreshPlayer</a>;
<a name="l00068"></a>00068         <span class="comment">// tutaj informacja by odswiezyc liste creepow</span>
<a name="l00069"></a><a class="code" href="class_logic_layer.html#aa965887d2920ef8344ff743e9c421d62">00069</a>         <span class="keywordtype">bool</span> <a class="code" href="class_logic_layer.html#aa965887d2920ef8344ff743e9c421d62">graphicsShouldRefreshCreeps</a>;
<a name="l00070"></a>00070         <span class="comment">// i pociskow</span>
<a name="l00071"></a><a class="code" href="class_logic_layer.html#aa97c5ce3cbeb13a157909b2a89f3f677">00071</a>         <span class="keywordtype">bool</span> <a class="code" href="class_logic_layer.html#aa97c5ce3cbeb13a157909b2a89f3f677">graphicsShouldRefreshBullets</a>;
<a name="l00072"></a>00072         <span class="comment">// czy pokazywac informacje o ilosci fps?</span>
<a name="l00073"></a><a class="code" href="class_logic_layer.html#a09cb7e24b330de168f35c2c21d3ccfa9">00073</a>         <span class="keywordtype">bool</span> <a class="code" href="class_logic_layer.html#a09cb7e24b330de168f35c2c21d3ccfa9">showFPSinfo</a>;
<a name="l00074"></a>00074         <span class="comment">// Funkcja okreslania celu dla gracza</span>
<a name="l00075"></a>00075         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#a303d7c816389f1b9ce335b0474af6f55">MovePlayer</a>(<a class="code" href="struct_point2_d.html">Point2D</a> newPos); 
<a name="l00076"></a>00076         <span class="comment">// Funkcja przesuwajaca gracza wzgledem jego aktualnej pozycji</span>
<a name="l00077"></a>00077         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#a303d7c816389f1b9ce335b0474af6f55">MovePlayer</a>(<span class="keywordtype">float</span> x,<span class="keywordtype">float</span> y);
<a name="l00078"></a>00078         <span class="comment">// Funkcja przenoszaca gracza bezposrednio na miejsce docelowe</span>
<a name="l00079"></a>00079         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#ade9b6ef524b7955d226231b31312b73d">TeleportPlayer</a>(<a class="code" href="struct_point2_d.html">Point2D</a> newPos);
<a name="l00080"></a>00080         <span class="comment">// Funkcja spawnujaca creepa w podanej pozycji</span>
<a name="l00081"></a>00081         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#a61b00b6e032f5b49944bbda89168f5fe">addCreep</a>(<a class="code" href="struct_point2_d.html">Point2D</a> pos,<span class="keywordtype">int</span> speed);
<a name="l00082"></a>00082         <span class="comment">// Funkcja &quot;sztucznej inteligencji&quot;, czyli w tym momencie podazania za graczem po skracaczu ukladu wspolrzednych        </span>
<a name="l00083"></a>00083         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#a53824273b681043d10e0b076e0377a4a">siCreepFollowPlayer</a>();
<a name="l00084"></a>00084         <span class="comment">// Funkcja powodujaca aktualizacje pozycji pociskow</span>
<a name="l00085"></a>00085         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#aead03de0ffce07b26924511fedfcb929">moveBullets</a>();
<a name="l00086"></a>00086         <span class="comment">// Glowna funkcja modulu - wywoluje pozostale i odpowiada za cala logike        </span>
<a name="l00087"></a>00087         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#a4d9c2566e4abf890a0c8be0e6f6d2f9b">doLogic</a>(); 
<a name="l00088"></a>00088         <span class="comment">// Funkcja odpowiadajaca za sterowanie</span>
<a name="l00089"></a>00089         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#afe4290339ee723909d1900a6f2562400">doSteering</a>();
<a name="l00090"></a>00090         <span class="comment">// Pobieranie instancji singletona</span>
<a name="l00091"></a><a class="code" href="class_logic_layer.html#ac63770d8bb2818a667f516368e1b13d7">00091</a>         <span class="keyword">static</span> <a class="code" href="class_logic_layer.html">LogicLayer</a>* <a class="code" href="class_logic_layer.html#ac63770d8bb2818a667f516368e1b13d7">getI</a>()
<a name="l00092"></a>00092         {
<a name="l00093"></a>00093                 <span class="keyword">static</span> <a class="code" href="class_logic_layer.html">LogicLayer</a> tmp;
<a name="l00094"></a>00094                 <span class="keywordflow">return</span> &amp;tmp;
<a name="l00095"></a>00095         }
<a name="l00096"></a>00096         <span class="comment">// Funkcja deinicjujaca</span>
<a name="l00097"></a>00097         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#a31a4249121666648251151874d544039">deinit</a>();
<a name="l00098"></a>00098         <span class="comment">// funkcja strzalu</span>
<a name="l00099"></a>00099         <span class="keywordtype">void</span> <a class="code" href="class_logic_layer.html#a1dc7cfb2fff93f48cb0419f15512ac1f">shot</a>();
<a name="l00100"></a>00100 };
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Fri Sep 30 2011 23:11:30 for The Grid by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
